<template>
	<view>
		<view class="side-navbar">
			<view class="side-navbar-wrapper">
				<!-- Sidebar Header    -->
				<view class="sidenav-header">
					<image mode='widthFix' src="/static/logo.png"></image>
				</view>
				<view class="gs">
					<view style="line-height: 22px;margin: 0px 0px 5px 0px;">{{propertyName}}</view>
					<view class="tc"><a @click="logout()">退出登录</a></view>
				</view>
				<!-- Sidebar Navigation Menus-->
				<view class="menu" style="margin-top: 30px;">
					<ul id="side-menu" class="side-menu list-unstyled">
						<li><a @click="conso()">
								<i class="ri-home-fill" style="color:#7800BE;font-size:12px;"></i>
								<!-- <i-icon size="20upx" color="#7800BE" name="home-fill"></i-icon> -->
								控制台
							</a></li>
					</ul>
				</view>

				<view class="menu">
					<h5 class="sidenav-heading">
						<i class="ri-pie-chart-2-fill" style="color:#7800BE;font-size:12px;"></i>
						<!-- <i-icon size="20upx" color="#7800BE" name="pie-chart-2-fill"></i-icon> -->
						订单查询
					</h5>
					<ul id="side-menu" class="side-menu list-unstyled">
						<li><a @click="order()">
								<i class="ri-arrow-right-s-line" style="color:#666;font-size:12px;"></i>
								<!-- <i-icon size="20upx" color="#666" name="arrow-right-s-line"></i-icon> -->
								服务订单
							</a></li>
						<li><a @click="orderfj()">
								<i class="ri-arrow-right-s-line" style="color:#666;font-size:12px;"></i>
								<!-- <i-icon size="20upx" color="#666" name="arrow-right-s-line"></i-icon> -->
								回收订单
							</a></li>
						<li><a @click="ordercw()">
								<i class="ri-arrow-right-s-line" style="color:#666;font-size:12px;"></i>
								<!-- <i-icon size="20upx" color="#666" name="arrow-right-s-line"></i-icon> -->
								财务流水
							</a></li>
							
					</ul>
				</view>
				<view class="menu">
					<h5 class="sidenav-heading">
						<i class="ri-money-cny-circle-fill" style="color:#7800BE;font-size:12px;"></i>
						<!-- <i-icon size="20upx" color="#7800BE" name="money-cny-circle-fill"></i-icon> -->
						企业电子账户
					</h5>
					<ul id="side-menu" class="side-menu list-unstyled">
						<li><a @click="accInfo()">
								<i class="ri-arrow-right-s-line" style="color:#666;font-size:12px;"></i>
								<!-- <i-icon size="20upx" color="#666" name="arrow-right-s-line"></i-icon> -->
								我的账户
							</a></li>
						<view v-if="qyState == 0">
							<li><a @click="qiye()">
									<i class="ri-arrow-right-s-line" style="color:#666;font-size:12px;"></i>
									<!-- <i-icon size="20upx" color="#666" name="arrow-right-s-line"></i-icon> -->
									创建企业电子账户
								</a></li>
						</view>
					</ul>
				</view>
				<view class="menu">
					<h5 class="sidenav-heading">
						<i class="ri-user-fill" style="color:#7800BE;font-size:12px;"></i>
						<!-- <i-icon size="20upx" color="#7800BE" name="user-fill"></i-icon> -->
						个人电子账户
					</h5>
					<ul id="side-menu" class="side-menu list-unstyled">
						<li>
							<a @click="accInfogr()">
								<i class="ri-arrow-right-s-line" style="color:#666;font-size:12px;"></i>
								<!-- <i-icon size="20upx" color="#666" name="arrow-right-s-line"></i-icon> -->
								我的账户
							</a>
						</li>
						<view v-if="grState == 0">
							<li>
								<a @click="geren()">
									<i class="ri-arrow-right-s-line" style="color:#666;font-size:12px;"></i>
									<!-- <i-icon size="20upx" color="#666" name="arrow-right-s-line"></i-icon> -->
									创建个人电子账户
								</a>
							</li>
						</view>
					</ul>
				</view>
			</view>
		</view>
		<view class="page">
			<iframe class="main" :src="tab" id="__show__1" name="content"></iframe>
			<view class="footer">
				<p><text style="margin-right: 5upx;">Copyright © 2022 桂民社区服务站</text>
					<text>Powered by 奇果科技</text>
				</p>
			</view>
		</view>
	</view>
	</view>
</template>
<script type="text/javascript">
	export default {
		data() {
			return {
				tab: '#/pages/admin/wuye-console',
				qyState: 0, //企业账号状态
				grState: 0, //个人账号状态
				propertyName: '广西南宁市青秀同望四海物业管理有限公司', //物业名称
			}
		},
		methods: {
			findAccType() {
				let _this = this;
				uni.request({
					url: this.baseURL + '/com/find/accType',
					method: 'POST',
					header: {
						"token": uni.getStorageSync('token')
					},
					success(res) {
						console.log(res)
						let rData = res.data.data;
						if (rData.propertyName != null) {
							_this.propertyName = rData.propertyName;
						}
						if (rData.qyAccount == '未开通') {
							_this.qyState = 0;
						} else {
							_this.qyState = 1;
						}
						if (rData.grAccount == '未开通') {
							_this.grState = 0;
						} else {
							_this.grState = 1;
						}
					},
					fail(err) {
						console.log(err)
						uni.showToast({
							title: err.message,
							icon: 'error',
							duration: 3000
						})
					}
				})
			},
			logout() {
				let tk = uni.getStorageSync('token');
				if (!tk) {
					uni.showToast({
						icon: 'error',
						title: 'token为空，您的登录状态为空',
						duration: 2000
					})
					setTimeout(function() {
						uni.reLaunch({
							url: '../login/login',
						})
					}, 2500)
				}
				uni.showLoading({})
				uni.request({
					url: this.baseURL + "/logout",
					method: 'GET',
					header: {
						token: uni.getStorageSync('token')
					},
					success: (res) => {
						console.log(res)
						uni.hideLoading()
						if (res.data.success == true) {
							uni.reLaunch({
								url: '../login/login'
							})
						}
					},
					fail: (err) => {
						uni.hideLoading()
						console.log(err)
						uni.showToast({
							icon: 'error',
							title: err.message
						})
					}
				})
			},
			conso() {
				this.tab = '#/pages/admin/wuye-console'
			},
			order() {
				this.tab = '#/pages/admin/order'
			},
			orderfj() {
				this.tab = '#/pages/admin/orderfj'
			},
			ordercw() {
				this.tab = '#/pages/admin/ordercw'
			},
			qiye() {
				this.tab = '#/pages/account/account-qy-add'
			},
			geren() {
				this.tab = '#/pages/account/account-gr-add'
			},
			accInfo() {
				this.tab = '#/pages/account/account-qy-info'
			},
			accInfogr() {
				this.tab = '#/pages/account/account-gr-info'
			}

		},
		onLoad: function() {
			this.findAccType();
		}
	}
</script>
